﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Shop.Core.Events;
using Shop.Core.Domain.Catalog;
using Shop.Core.Data;
using Shop.Core.Data.Catalog;

namespace Shop.Service.Catalog
{
    public class ProductService : IProductService
        , IConsumer<EntityRequired<Product, string>>
    {
        public IProductRepository ProductRepository
        {
            get;
            protected set;
        }

        public ProductService(IProductRepository productRepository)
        {
            this.ProductRepository = productRepository;
        }

        public Product GetProduct(string id)
        {
            return this.ProductRepository.GetById(id);
        }

        public IList<Product> GetProduct(IList<string> idList)
        {
            throw new NotImplementedException();
        }

        public void HandleEvent(EntityRequired<Product, string> eventMessage)
        {
            eventMessage.Result = this.GetProduct(eventMessage.Id);
        }
    }
}
